home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / d.t.p / utils / propage / donsgenies / donsgenies.lha / Don'sGenies / BoxesCentreOnPage.pprx < prev    next >
Text File  |  1993-05-25  |  2KB  |  82 lines

  1. /* This Genie centres the boxes on the page, from left to right only (not top-to-bottom).
  2. Written by Don Cox  Aug 92. Not Public Domain. All rights reserved. Copyright but freely usable for non-commercial purposes. */
  3.  
  4. trace n
  5. signal on error
  6. signal on syntax
  7. address command
  8. call SafeEndEdit.rexx()
  9. call ppm_AutoUpdate(0)
  10. cr="0a"x
  11.  
  12. cpage = ppm_CurrentPage()
  13. counter=0
  14.  
  15. choice = ppm_Inform(2,"Which boxes?","All on page","Click to select")
  16.  
  17. select
  18. when choice = 1 then do
  19.     do forever
  20.         box=ppm_ClickOnBox("  Click on boxes to be repositioned")
  21.         if box=0 then break
  22.         counter=counter+1
  23.         boxes.counter=box
  24.         call ppm_SelectBox(box)
  25.         end
  26.     end
  27.  
  28. when choice = 0 then do
  29.     boxes.1 = ppm_PageFirstBox()
  30.     box = boxes.1
  31.     totalboxes = ppm_NumBoxes(cpage)
  32.     counter = totalboxes
  33.     do i=2 to totalboxes
  34.         box = ppm_PageNextBox(box)
  35.         boxes.i = box
  36.         end
  37.     end
  38.  
  39. otherwise exit_msg()
  40. end
  41.  
  42. if counter=0 then exit_msg("No boxes selected")
  43. currentunits=ppm_GetUnits()
  44. call ppm_SetUnits(2)
  45.  
  46. pagewidth = word(ppm_GetPageSize(),1)
  47.  
  48. call ppm_ShowStatus("  Centring boxes...")
  49. do i=1 to counter
  50.     box=boxes.i
  51.  
  52.     Ypos = word(ppm_GetBoxPosition(box),2)
  53.     width = word(ppm_GetBoxSize(box),1)
  54.     Xpos = (pagewidth-width)/2
  55.     call ppm_SetBoxPosition(box,Xpos,Ypos)
  56.  
  57.     end
  58.  
  59. call ppm_SetUnits(currentunits)
  60.  
  61. call exit_msg()
  62. end
  63.  
  64.  
  65.  
  66. error:
  67. syntax:
  68.     do
  69.     exit_msg("Genie failed due to error: "errortext(rc))
  70.     end
  71.  
  72. exit_msg:
  73.     do
  74.     parse arg message
  75.     if message ~= "" then
  76.     call ppm_Inform(1,message,"Resume")
  77.     call ppm_ClearStatus()
  78.     call ppm_AutoUpdate(1)
  79.     exit
  80.     end
  81.  
  82.